<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <link type="text/css" href="styles/base/ui.all.css" rel="stylesheet" />
    <style type="text/css" media="screen">
        @import url("styles/gb.css");
    </style>
    <script src="/_utils/script/json2.js"></script> 
    <script src="/_utils/script/sha1.js"></script> 
    <script src="/_utils/script/jquery.js?1.4.2"></script> 
    <script src="/_utils/script/jquery.couch.js?0.11.0"></script> 
    <script src="/_utils/script/jquery.dialog.js?0.11.0"></script> 
    <script src="/_utils/script/futon.js?0.11.0"></script> 
    <script src="/_utils/script/jquery.resizer.js?0.11.0"></script> 
    <script src="/_utils/script/couch.js?0.11.0"></script> 
	<script type="text/javascript" src="scripts/navigation.js"></script>
	<script type="text/javascript" src="scripts/jquery.corner.js"></script>
	<script type="text/javascript">
		var db_name;
		var db;
	
		$(function() {
		
			db_name = findDBName();
			db = new CouchDB(db_name, {"X-Couch-Full-Commit":"true"});
			try {
				db.info();
			} catch (e) {
				$('#control_panel').show();
				$('#db_name').text(db_name);
				$('#initButton').click(function() {
					initDB();
					$(this).hide();
				});
			}
			
		});
		
		
		function initDB() {
			  db.createDb();
			  createConverastionDesignDoc(db);
			  createPersonDesignDoc(db);
			  createProjectDesignDoc(db);
			  createTagsDesignDoc(db);
			  createTestDesignDoc(db);
			  $('#success').show();
		
		}
		
		
		
		function createTestDesignDoc(db) {
			$.getJSON("design_docs/test.json", function(doc){
				db.save(doc);
			});		
		}
		
		function createTagsDesignDoc(db) {
			$.getJSON("design_docs/tags.json", function(doc){
				db.save(doc);
			});
		}		
		function createConverastionDesignDoc(db) {
			$.getJSON("design_docs/conversation.json", function(doc){
				db.save(doc);
			});
		}
		
		function createProjectDesignDoc(db) {
			$.getJSON("design_docs/project.json", function(doc){
				db.save(doc);
			});
		}
		
		function createPersonDesignDoc(db) {
			$.getJSON("design_docs/person.json", function(doc){
				db.save(doc);
			});
		
		}
		
		
		
	</script>
  </head>
  <body class="primary-4">
	<div id="header"></div>
    <div id="content" data-corner="left right 20px">
		<div id="conversation_details">
			<div class="font-2"><span id="c_name">Configuration</span></div>
		</div>
	
		<div id="control_panel" style="display: none;">
			The database <span id="db_name">DBNAME</span> has not been created. Click the following 
			button to create and initialize this database.
		
			<input type="button" value="Initialize" id="initButton"/>
			
			<div id="success" style="display: none;">
				The initialization was successful.
			</div>
			
			
			
			
		
		</div>
	
	
	
	
    </div>
  </body>
</html>
